package com.ruoyi.web.controller.production.blade;

import java.util.List;

import com.ruoyi.common.annotation.PropertyInject;
import com.ruoyi.common.enums.InjectType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.production.domain.blade.BladeAmount;
import com.ruoyi.production.service.blade.IBladeAmountService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 刀片量Controller
 *
 * @author ruoyi
 * @date 2021-07-12
 */
@RestController
@RequestMapping("/production/bladeAmount")
public class BladeAmountController extends BaseController
{
    @Autowired
    private IBladeAmountService bladeAmountService;

    /**
     * 查询刀片量列表
     */
    @PreAuthorize("@ss.hasPermi('production:bladeAmount:list')")
    @GetMapping("/list")
    public TableDataInfo list(BladeAmount bladeAmount)
    {
        startPage();
        List<BladeAmount> list = bladeAmountService.selectBladeAmountList(bladeAmount);
        return getDataTable(list);
    }

    /**
     * 导出刀片量列表
     */
    @PreAuthorize("@ss.hasPermi('production:bladeAmount:export')")
    @Log(title = "刀片量", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BladeAmount bladeAmount)
    {
        List<BladeAmount> list = bladeAmountService.selectBladeAmountList(bladeAmount);
        ExcelUtil<BladeAmount> util = new ExcelUtil<BladeAmount>(BladeAmount.class);
        return util.exportExcel(list, "刀片量数据");
    }

    /**
     * 获取刀片量详细信息
     */
    @PreAuthorize("@ss.hasPermi('production:bladeAmount:query')")
    @GetMapping(value = "/{bladeAmountId}")
    public AjaxResult getInfo(@PathVariable("bladeAmountId") Long bladeAmountId)
    {
        return AjaxResult.success(bladeAmountService.selectBladeAmountById(bladeAmountId));
    }

    /**
     * 新增刀片量
     */
    @PreAuthorize("@ss.hasPermi('production:bladeAmount:add')")
    @Log(title = "刀片量", businessType = BusinessType.INSERT)
    @PostMapping
    @PropertyInject(type = InjectType.Insert)
    public AjaxResult add(@RequestBody BladeAmount bladeAmount)
    {
        return toAjax(bladeAmountService.insertBladeAmount(bladeAmount));
    }

    /**
     * 修改刀片量
     */
    @PreAuthorize("@ss.hasPermi('production:bladeAmount:edit')")
    @Log(title = "刀片量", businessType = BusinessType.UPDATE)
    @PutMapping
    @PropertyInject(type = InjectType.Update)
    public AjaxResult edit(@RequestBody BladeAmount bladeAmount)
    {
        return toAjax(bladeAmountService.updateBladeAmount(bladeAmount));
    }

    /**
     * 删除刀片量
     */
    @PreAuthorize("@ss.hasPermi('production:bladeAmount:remove')")
    @Log(title = "刀片量", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bladeAmountIds}")
    public AjaxResult remove(@PathVariable Long[] bladeAmountIds)
    {
        return toAjax(bladeAmountService.deleteBladeAmountByIds(bladeAmountIds));
    }
}
